//
//  CustomCollectionFooter.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/1.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "CustomCollectionFooter.h"
#define mButtonW 134.f

@implementation CustomCollectionFooter


- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self == [super initWithFrame:frame])
    {
                
        //按钮
        NSArray *titles = @[@"重置", @"确定"];
        NSArray *colors = @[UIColorFromRGB(0xC0C0C0), KWhiteColor];
        float gap = (KScreenWidth -mButtonW *2 - 15)/2.0;
        @weakify(self);
        [titles enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            @strongify(self);
            
            UIButton *button = [UIButton makeButtonWithText:obj textColor:colors[idx] font:mFont(14) textAliment:1 cornerRadius:5];
            button.size = CGSizeMake(mButtonW, 38);
            button.mj_y = 25;
            button.mj_x = gap + (mButtonW+15)*idx;
            [self addSubview:button];
            
            if (idx == 0) {
                button.layer.borderColor = UIColorFromRGB(0xD8D8D8).CGColor;
                button.layer.borderWidth = 1;
            }else{
                [button setBackgroundImage:[UIImage imageNamed:@"meat_buy_bg"] forState:UIControlStateNormal];
            }
            
            button.tapBlock = ^{
                
                if (idx == 0) {
                    
                    if (self.dealReSetBlock) {
                        self.dealReSetBlock();
                    }
                    
                }else{
                    
                    if (self.dealOkBlock) {
                        self.dealOkBlock();
                    }
                }
            };
        }];
        
        //线条
        CAShapeLayer *line = [CAShapeLayer layer];
        line.fillColor = mIconLineColor.CGColor;
        UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 10, KScreenWidth, 1)];
        line.path = path.CGPath;
        [self.layer addSublayer:line];
        
        
    }
    return self;
}

@end
